package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private TextView btn1, btn2, btn3, btn4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        setTitle("学习英语");
        btn1 = findViewById(R.id.tv1);
        btn2 = findViewById(R.id.tv2);
        btn3 = findViewById(R.id.tv3);
        btn4 = findViewById(R.id.tv4);

        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String s = (String) ((TextView)v).getText();
                Intent intent = new Intent(MainActivity.this, ExerciseActivity.class);
                Bundle bundle = new Bundle();
                bundle.putString("title", s);
                intent.putExtras(bundle);
                startActivity(intent);
            }
        };

        btn1.setOnClickListener(listener);
        btn2.setOnClickListener(listener);
        btn3.setOnClickListener(listener);
        btn4.setOnClickListener(listener);
    }
}